package annotation;

import java.lang.annotation.*;

/**
 * @author louzhuangxi
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.FIELD, ElementType.TYPE})
@Inherited
@Repeatable(value = MyAnnotations.class)
public @interface MyAnnotation {
    String value();
}

/**
 * @author louzhuangxi
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.FIELD, ElementType.TYPE})
@Inherited
@interface MyAnnotations {
    MyAnnotation[] value();
}

//@MyAnnotation(value = "123")
//@MyAnnotation(value = "abc")
@MyAnnotations(value = {@MyAnnotation(value = "456"), @MyAnnotation("def")})
class MyAnnotationTest {
    public static void main(String[] args) {
        Class<MyAnnotationTest> myAnnotationTestClass = MyAnnotationTest.class;
        Annotation[] declaredAnnotations = myAnnotationTestClass.getDeclaredAnnotations();
        for (Annotation declaredAnnotation : declaredAnnotations) {
            System.out.println(declaredAnnotation);
        }

        System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");

        MyAnnotations declaredAnnotation = myAnnotationTestClass.getDeclaredAnnotation(MyAnnotations.class);
        System.out.println(declaredAnnotation);


    }
}
